//
//	File: OyD3D9FontRender.h
//

#ifndef OYD3D9FONTRENDER_H
#define OYD3D9FONTRENDER_H

#include <d3d9.h>

class OyDirect3D9;
struct OY_FONT_VERTEX_TYPE;

class OyD3D9_FontBuffer
{
public:
	OyD3D9_FontBuffer(LPDIRECT3DTEXTURE9 pTexture, LPDIRECT3DDEVICE9 pDevice, OyDirect3D9 *pOyD3D9);
	~OyD3D9_FontBuffer();

	void	PushVertex(OY_FONT_VERTEX_TYPE FourVerts[4]);
	bool	IsBufferFull() { return( m_nNumTris >= MAX_CHAR_IN_BUFFER * 2 ); }
	HRESULT	Flush();

	void	OnDeviceLost();
	void	OnDeviceReset();

private:
	USHORT							m_nNumTris;

	LPDIRECT3DTEXTURE9				m_pTexture;
	LPDIRECT3DVERTEXDECLARATION9	m_pDecl;
	LPDIRECT3DVERTEXBUFFER9			m_pVB;
	LPDIRECT3DINDEXBUFFER9			m_pIB;

	LPDIRECT3DDEVICE9				m_pDevice;

private:
	static const unsigned short		MAX_CHAR_IN_BUFFER = 128;
	OY_FONT_VERTEX_TYPE				*m_pCachedVertex;
	WORD							*m_pCachedIndex;
};


#endif